package org.yufan.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.yufan.bean.User;

import java.util.Date;

public interface UserRepository extends JpaRepository<User,Long> {

    public User findUserByUsernameAndPassword(String username,String password);

    public User findUserByUsername(String username);

    public User findUserByPhone(String phone);

    public User findUserByEmail(String email);

    @Modifying
    @Query("update User u set lastLoginTime=:date where u.id=:id")
    public void updateUserLastLoginTime(@Param("date") Date date, @Param("id") Long id);

}
